<?php 
    class NguoidungController extends BaseController{
        public static function login(){ 
            $tendangnhap = Input::get('txtTenDN');
            $matkhau = Input::get('txtMatKhau');
            $check = Nguoidung::where("tendangnhap","=",$tendangnhap)->where("matkhau","=",$matkhau)->count();
            if($check > 0){
                $hoten= Nguoidung::where("tendangnhap","=",$tendangnhap)->first();
                $ns = date("md",strtotime($hoten->ngaysinh));
                $nht = date("md");                
                $nht_str = date("md",strtotime($nht));
                if($ns==$nht_str){Session::put("ngaysinh",true);}
                Session::put("dangnhap",$hoten->hoten);                
                return Redirect::to('index');
            }                
            else return Redirect::to('master');
        }  
        public static function logout(){
            Session::flush();
            return Redirect::to('index');
        }     
    }
?>